<template>
  <div v-if="Object.keys(commentInfo).length !== 0" class="comment-info">
    <div class="info-header">
      <div class="header-title">用户评价</div>
      <div class="header-more">
        更多
        <i class="arrow-right"></i>
      </div>
    </div>

    <div class="info-user">
      <img :src="commentInfo.list[0].user.avatar" alt="">
      <span>{{commentInfo.list[0].user.uname}}</span>
    </div>

    <div class="info-detail">
      <p>{{commentInfo.list[0].content}}</p>
      <div class="info-other">
        <span class="date">{{commentInfo.list[0].created | formaltime}}</span>
        <span>{{commentInfo.list[0].style}}</span>
      </div>

      <div class="info-imgs">
        <img :src="item" v-for="(item,index) in commentInfo.list[0].images" :key="index">
      </div>
    </div>
  </div>
</template>

<script>

  import {
    formatDate
  } from "common/utils"

  export default {
    name: "DetailComments",
    props:{
      commentInfo:{
        type:Object,
        dafault(){
          return {}
        }}

    },
    filters:{
      formaltime(time){
        //1.将时间戳转成Date对象
        const date = new Date(time*1000)

        //2.将date进行格式化
        return formatDate(date, "yyyy-MM-dd")
      }
    }

  }
</script>

<style scoped>
  .comment-info{
    padding: 15px 12px;
    border-bottom: 5px solid #f2f5f8;
  }

  .info-header{
    border-bottom: 1px solid #f6f6f6;
    padding-bottom: 15px;
    margin-bottom: 10px;
  }

  .header-more{
    float: right;
    font-size: 14px;
    margin-right: 10px;}

  .arrow-right{
    border-top: 1px solid #999;
    border-left: 1px solid #999;
    width: 9px;
    height: 9px;
    background-color: transparent;
    -webkit-transform: rotate(135deg);
    transform: rotate(135deg);
    display: inline-block;
    margin-left: .1rem;
  }

  .info-user img{
    width: 42px;
    height: 42px;
    border-radius: 50%;
  }
  .info-user span{
    vertical-align: 15px;
    margin-left: 10px;
  }
  .info-detail{
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.5em;
  }
  .info-other {
    margin-top: 10px;
    font-size: 12px;
  }
  .info-other span{
    margin-right: 10px;
  }
  .info-imgs img{
    width: 70px;
    margin: 10px 10px 0 0;
  }

</style>
